import { axios } from '@/utils/request';

/**
 * login func
 * parameters:{
 *    userId:'',
 *    password: ''
 * }
 * @param parameter
 * @returns {*}
 */
export function login (parameter) {
  return axios({
    url: '/login',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}

/**
 * getPermissionListById func
 * parameters:{
 *    workId:''
 * }
 * @param parameter
 * @returns {*}
 */
export function getPermissionListById (parameter) {
  return axios({
    url: '/getpermissionlist',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}


/**
 * logout func
 * @param
 * @returns {*}
 */
export function logout () {
  return axios({
    url: '/logout',
    method: 'post',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}

/**
 * addUser func
 * @param
 * @returns {*}
 */
export function addUser (parameter) {
  return axios({
    url: '/user/add',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}

/**
 * editUser func
 * @param
 * @returns {*}
 */
export function editUser (parameter) {
  console.log(parameter);
  return axios({
    url: '/user/update',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}

/**
 * editUser func
 * @param
 * @returns {*}
 */
export function resetPwUser (parameter) {
  return axios({
    url: '/user/resetpwd',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}

/**
 * deleteUser func
 * @param
 * @returns {*}
 */
export function deleteUser (parameter) {
  return axios({
    url: '/user/del',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}

/**
 * getUser func
 * @param
 * @returns {*}
 */
export function getUser (parameter) {
  return axios({
    url: '/user/info',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}

/**
 * getUsers func
 * @param
 * @returns {*}
 */
export function getUsers (parameter) {
  return axios({
    url: '/user/list',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}

/**
 * getSimpleUsers 获得大致人员列表 func
 * @param
 * @returns {*}
 */
export function getSimpleUsers () {
  return getUsers({ type: "S" })
}



/**
 * changePasswordUser func
 * @param
 * @returns {*}
 */
export function changePasswordUser (parameter) {
  return axios({
    url: '/user/chgpwd',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}

/**
 * checkUserExist func
 * @param
 * @returns {*}
 */
export function checkUserExist (parameter) {
  return axios({
    url: '/user/isexist',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}


/**
 * checkUserExist func
 * @param
 * @returns {*}
 */
export function getLoginQr (parameter) {
  return axios({
    url: '/codenew',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}


/**
 * checkUserExist func
 * @param
 * @returns {*}
 */
export function checkLoginQrResult (parameter) {
  return axios({
    url: '/codelogin',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}

/**
 * LoginByPortalToken func
 * @param
 * @returns {*}
 */
export function LoginByPortalToken (parameter) {
  return axios({
    url: '/portallogin',
    method: 'post',
    data: parameter,
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  });
}